from enum import Enum

class DialogState(Enum):
    INIT = 0
    WAITING_FOR_INPUT = 1
    PROCESSING = 2
    RESPONDING = 3
    END = 4

class DialogManager:
    def __init__(self):
        self.state = DialogState.INIT
        self.context = {}
        
    def handle(self, processed_text):
        """处理输入文本并返回响应"""
        if self.state == DialogState.INIT:
            self.state = DialogState.WAITING_FOR_INPUT
            return "你好！我是你的语音助手，请问有什么可以帮你的吗？"
            
        elif self.state == DialogState.WAITING_FOR_INPUT:
            self.state = DialogState.PROCESSING
            self.context['user_input'] = processed_text
            return "正在处理你的请求..."
            
        elif self.state == DialogState.PROCESSING:
            self.state = DialogState.RESPONDING
            return self._generate_response(processed_text)
            
        elif self.state == DialogState.RESPONDING:
            self.state = DialogState.WAITING_FOR_INPUT
            return "还有其他问题吗？"
            
        else:
            return "对话已结束"
    
    def _generate_response(self, text):
        """根据上下文生成响应"""
        # 这里可以扩展为更复杂的对话逻辑
        return f"我理解你说的是: {text}"